package com.example.project1

import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import android.widget.LinearLayout
import android.widget.ImageView

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
//        setContentView(R.layout.activity_main)
        val linearLayout= LinearLayout(this)
        linearLayout.orientation=LinearLayout.VERTICAL
        val textView=TextView(this)
        textView.text=getString(R.string.app_name)
        val imageView= ImageView(this)
        imageView.setImageResource(R.drawable.flag)
        val button= Button(this)
        button.text=getString(R.string.click)
        linearLayout.addView(textView)
        linearLayout.addView(imageView)
        linearLayout.addView(button)
        setContentView(linearLayout)

        ViewCompat.setOnApplyWindowInsetsListener(linearLayout) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
//        val button = findViewById<Button>(R.id.button)

        button.setOnClickListener {
//            val textView = findViewById<TextView>(R.id.textView)
            textView.text = getString(R.string.textView)
        }
    }
}